package com.gzc.just.play.last.war.centralserver.quest.repository;

import com.gzc.just.play.last.war.centralserver.quest.model.Quest;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface QuestRepository extends JpaRepository<Quest, Long> {
    
    List<Quest> findByLevelRequiredLessThanEqualOrderByLevelRequired(Integer level);
    
    List<Quest> findByTypeOrderByLevelRequired(String type);
    
    @Query("SELECT q FROM Quest q WHERE q.levelRequired BETWEEN :minLevel AND :maxLevel ORDER BY q.levelRequired")
    List<Quest> findQuestsByLevelRange(@Param("minLevel") Integer minLevel, @Param("maxLevel") Integer maxLevel);
    
    @Query("SELECT q FROM Quest q WHERE q.prerequisites IS NOT NULL AND q.prerequisites <> ''")
    List<Quest> findQuestsWithPrerequisites();
}